<?php

namespace falcon5\inc\Helpers;

use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\CacheItem;

class FileCacheHelper
{
    public static function set(string $key, $value = null): bool
    {
        /** @var FilesystemAdapter $cache */
        $cache = falcon5_app('fileCache');
        /** @var CacheItem $item */
        $item = $cache->getItem($key);
        $item->set($value);
        return $cache->save($item);
    }

    public static function get(string $key)
    {
        /** @var FilesystemAdapter $cache */
        $cache = falcon5_app('fileCache');
        return $cache->getItem($key);
    }

    public static function delAll()
    {
        /** @var FilesystemAdapter $cache */
        $cache = falcon5_app('fileCache');
        return $cache->clear();
    }

    public static function del(string $key)
    {
        $cache = falcon5_app('fileCache');
        return $cache->deleteItem($key);
    }
}